const lineParams = ['women', 'men']

export type LineDataRecord = {
  x: number | undefined;
  y: string | undefined;
}

export function processLineData (data: DataRecord[]): LineDataRecord[] {
  const newData: LineDataRecord[] = []
  data.forEach((d: DataRecord) => {
    lineParams.forEach((param: string) => {
      const dataPoint: LineDataRecord = { x: undefined, y: undefined }
      dataPoint.x = d[param] ? d[param] : undefined
      dataPoint.y = d[param] ? d.occupation : undefined
      newData.push(dataPoint)
    })
    // we have to push an extra data point here to break the line
    newData.push({ x: undefined, y: undefined })
  })
  return newData
}

export type DataRecord = {
  occupation: string;
  category?: string;
  men: number;
  women: number;
  gap: number;
  percentage: number;
};

export const data = [
  {
    occupation: 'Admin and organisation',
    category: 'admin and organisation',
    women: 43801,
    men: 55149,
    gap: 11348,
    percentage: 0.2362,
  },
  {
    occupation: 'HR managers',
    category: 'admin and organisation',
    women: 67600,
    men: 95004,
    gap: 27404,
    percentage: 0.4054,
  },
  {
    occupation: 'Production clerks',
    category: 'admin and organisation',
    women: 38376,
    men: 53248,
    gap: 14872,
    percentage: 0.3875,
  },
  {
    occupation: 'Human resources',
    category: 'admin and organisation',
    women: 47424,
    men: 65364,
    gap: 17940,
    percentage: 0.3783,
  },
  {
    occupation: 'Accountants',
    category: 'admin and organisation',
    women: 51948,
    men: 64272,
    gap: 12324,
    percentage: 0.2372,
  },
  {
    occupation: 'Education admin',
    category: 'admin and organisation',
    women: 60892,
    men: 74828,
    gap: 13936,
    percentage: 0.2289,
  },
  {
    occupation: 'Secretaries',
    category: 'admin and organisation',
    women: 35620,
    men: 42172,
    gap: 6552,
    percentage: 0.1839,
  },
  {
    occupation: 'Receptionists',
    category: 'admin and organisation',
    women: 27664,
    men: 32032,
    gap: 4368,
    percentage: 0.1579,
  },
  {
    occupation: 'Data entry keyers',
    category: 'admin and organisation',
    women: 32136,
    men: 34996,
    gap: 2860,
    percentage: 0.089,
  },
  {
    occupation: 'Office clerks',
    category: 'admin and organisation',
    women: 32552,
    men: 34424,
    gap: 1872,
    percentage: 0.0575,
  },
  {
    occupation: 'Care and education',
    category: 'care and education',
    women: 44210,
    men: 52827,
    gap: 8616,
    percentage: 0.1748,
  },
  {
    occupation: 'Doctors and surgeons',
    category: 'care and education',
    women: 64792,
    men: 104104,
    gap: 39312,
    percentage: 0.6067,
  },
  {
    occupation: 'Teacher assistants',
    category: 'care and education',
    women: 25688,
    men: 30160,
    gap: 4472,
    percentage: 0.1741,
  },
  {
    occupation: 'Social services',
    category: 'care and education',
    women: 50856,
    men: 59384,
    gap: 8528,
    percentage: 0.1677,
  },
  {
    occupation: 'Healthcare support',
    category: 'care and education',
    women: 25584,
    men: 29120,
    gap: 3536,
    percentage: 0.1382,
  },
  {
    occupation: 'Nursing',
    category: 'care and education',
    women: 24232,
    men: 27456,
    gap: 3224,
    percentage: 0.133,
  },
  {
    occupation: 'Physical therapists',
    category: 'care and education',
    women: 67964,
    men: 76856,
    gap: 8892,
    percentage: 0.1308,
  },
  {
    occupation: 'Secondary school',
    category: 'care and education',
    women: 51168,
    men: 57616,
    gap: 6448,
    percentage: 0.126,
  },
  {
    occupation: 'Emergency medical',
    category: 'care and education',
    women: 36868,
    men: 41132,
    gap: 4264,
    percentage: 0.1157,
  },
  {
    occupation: 'Special education',
    category: 'care and education',
    women: 51324,
    men: 56056,
    gap: 4732,
    percentage: 0.0922,
  },
  {
    occupation: 'Social workers',
    category: 'care and education',
    women: 43628,
    men: 46384,
    gap: 2756,
    percentage: 0.0632,
  },
  {
    occupation: 'Creative and media',
    category: 'creative and media',
    women: 46280,
    men: 57009,
    gap: 10729,
    percentage: 0.2311,
  },
  {
    occupation: 'Web developers',
    category: 'creative and media',
    women: 51376,
    men: 64740,
    gap: 13364,
    percentage: 0.2601,
  },
  {
    occupation: 'Designers',
    category: 'creative and media',
    women: 42224,
    men: 53040,
    gap: 10816,
    percentage: 0.2562,
  },
  {
    occupation: 'Arts and media',
    category: 'creative and media',
    women: 45240,
    men: 53248,
    gap: 8008,
    percentage: 0.177,
  },
  {
    occupation: 'Law and justice',
    category: 'law and justice',
    women: 31601,
    men: 40444,
    gap: 8843,
    percentage: 0.2622,
  },
  {
    occupation: 'Legal occupations',
    category: 'law and justice',
    women: 52052,
    men: 91780,
    gap: 39728,
    percentage: 0.7632,
  },
  {
    occupation: 'Protective services',
    category: 'law and justice',
    women: 32084,
    men: 46072,
    gap: 13988,
    percentage: 0.436,
  },
  {
    occupation: 'Police officers',
    category: 'law and justice',
    women: 38636,
    men: 54236,
    gap: 15600,
    percentage: 0.4038,
  },
  {
    occupation: 'Lawyers',
    category: 'law and justice',
    women: 82680,
    men: 99580,
    gap: 16900,
    percentage: 0.2044,
  },
  {
    occupation: 'Security',
    category: 'law and justice',
    women: 26728,
    men: 30628,
    gap: 3900,
    percentage: 0.1459,
  },
  {
    occupation: 'Bailiffs and jailers',
    category: 'law and justice',
    women: 35724,
    men: 39260,
    gap: 3536,
    percentage: 0.099,
  },
  {
    occupation: 'Traffic clerks',
    category: 'law and justice',
    women: 29952,
    men: 31356,
    gap: 1404,
    percentage: 0.0469,
  },
  {
    occupation: 'Manual Work',
    category: 'manual work',
    women: 24632,
    men: 30462,
    gap: 5829,
    percentage: 0.2382,
  },
  {
    occupation: 'Construction II',
    category: 'manual work',
    women: 26468,
    men: 39728,
    gap: 13260,
    percentage: 0.501,
  },
  {
    occupation: 'Production workers',
    category: 'manual work',
    women: 25584,
    men: 35152,
    gap: 9568,
    percentage: 0.374,
  },
  {
    occupation: 'Metal workers',
    category: 'manual work',
    women: 26572,
    men: 33644,
    gap: 7072,
    percentage: 0.2661,
  },
  {
    occupation: 'Grounds maintenance',
    category: 'manual work',
    women: 21476,
    men: 26884,
    gap: 5408,
    percentage: 0.2518,
  },
  {
    occupation: 'Fishing',
    category: 'manual work',
    women: 19500,
    men: 23764,
    gap: 4264,
    percentage: 0.2187,
  },
  {
    occupation: 'Farmers',
    category: 'manual work',
    women: 19188,
    men: 22724,
    gap: 3536,
    percentage: 0.1843,
  },
  {
    occupation: 'Electrical workers',
    category: 'manual work',
    women: 26312,
    men: 31096,
    gap: 4784,
    percentage: 0.1818,
  },
  {
    occupation: 'Packers',
    category: 'manual work',
    women: 20540,
    men: 23868,
    gap: 3328,
    percentage: 0.162,
  },
  {
    occupation: 'Laborers',
    category: 'manual work',
    women: 24752,
    men: 28392,
    gap: 3640,
    percentage: 0.1471,
  },
  {
    occupation: 'Construction',
    category: 'manual work',
    women: 35932,
    men: 39364,
    gap: 3432,
    percentage: 0.0955,
  },
  {
    occupation: 'Sales and serving others',
    category: 'sales and serving others',
    women: 27798,
    men: 35044,
    gap: 7245,
    percentage: 0.2454,
  },
  {
    occupation: 'Bartenders',
    category: 'sales and serving others',
    women: 23868,
    men: 32968,
    gap: 9100,
    percentage: 0.3813,
  },
  {
    occupation: 'Recreation and fitness',
    category: 'sales and serving others',
    women: 27092,
    men: 37232,
    gap: 10140,
    percentage: 0.3743,
  },
  {
    occupation: 'Real estate',
    category: 'sales and serving others',
    women: 37752,
    men: 51532,
    gap: 13780,
    percentage: 0.365,
  },
  {
    occupation: 'Drivers',
    category: 'sales and serving others',
    women: 28340,
    men: 38428,
    gap: 10088,
    percentage: 0.356,
  },
  {
    occupation: 'Insurance sales',
    category: 'sales and serving others',
    women: 36296,
    men: 49192,
    gap: 12896,
    percentage: 0.3553,
  },
  {
    occupation: 'Clergy',
    category: 'sales and serving others',
    women: 39676,
    men: 52364,
    gap: 12688,
    percentage: 0.3198,
  },
  {
    occupation: 'Janitors',
    category: 'sales and serving others',
    women: 21580,
    men: 28080,
    gap: 6500,
    percentage: 0.3012,
  },
  {
    occupation: 'Waiters and waitresses',
    category: 'sales and serving others',
    women: 21580,
    men: 26052,
    gap: 4472,
    percentage: 0.2072,
  },
  {
    occupation: 'Chefs and head cooks',
    category: 'sales and serving others',
    women: 27612,
    men: 31252,
    gap: 3640,
    percentage: 0.1318,
  },
  {
    occupation: 'Cashiers',
    category: 'sales and serving others',
    women: 20124,
    men: 21424,
    gap: 1300,
    percentage: 0.0646,
  },
  {
    occupation: 'Bus drivers',
    category: 'sales and serving others',
    women: 30264,
    men: 32032,
    gap: 1768,
    percentage: 0.0584,
  },
  {
    occupation: 'Food service',
    category: 'sales and serving others',
    women: 19396,
    men: 19968,
    gap: 572,
    percentage: 0.0295,
  },
  {
    occupation: 'Science, tech and engineering',
    category: 'science, tech and engineering',
    women: 48919,
    men: 59154,
    gap: 10235,
    percentage: 0.2223,
  },
  {
    occupation: 'Inspectors and testers',
    category: 'science, tech and engineering',
    women: 30056,
    men: 42640,
    gap: 12584,
    percentage: 0.4187,
  },
  {
    occupation: 'Production',
    category: 'science, tech and engineering',
    women: 26104,
    men: 36972,
    gap: 10868,
    percentage: 0.4163,
  },
  {
    occupation: 'Engineering',
    category: 'science, tech and engineering',
    women: 40820,
    men: 55432,
    gap: 14612,
    percentage: 0.358,
  },
  {
    occupation: 'Medical scientists',
    category: 'science, tech and engineering',
    women: 59332,
    men: 75348,
    gap: 16016,
    percentage: 0.2699,
  },
  {
    occupation: 'IT support',
    category: 'science, tech and engineering',
    women: 43524,
    men: 54548,
    gap: 11024,
    percentage: 0.2533,
  },
  {
    occupation: 'Physical scientists',
    category: 'science, tech and engineering',
    women: 65624,
    men: 80444,
    gap: 14820,
    percentage: 0.2258,
  },
  {
    occupation: 'Architecture',
    category: 'science, tech and engineering',
    women: 60216,
    men: 73476,
    gap: 13260,
    percentage: 0.2202,
  },
  {
    occupation: 'Social science',
    category: 'science, tech and engineering',
    women: 55224,
    men: 64844,
    gap: 9620,
    percentage: 0.1742,
  },
  {
    occupation: 'Programmers',
    category: 'science, tech and engineering',
    women: 65156,
    men: 75244,
    gap: 10088,
    percentage: 0.1548,
  },
  {
    occupation: 'Civil engineers',
    category: 'science, tech and engineering',
    women: 66300,
    men: 73112,
    gap: 6812,
    percentage: 0.1027,
  },
  {
    occupation: 'Lab techs',
    category: 'science, tech and engineering',
    women: 42536,
    men: 45656,
    gap: 3120,
    percentage: 0.0733,
  },
  {
    occupation: 'Health technicians',
    category: 'science, tech and engineering',
    women: 32136,
    men: 32136,
    gap: 0,
    percentage: 0,
  },
  {
    occupation: 'Senior managers and execs',
    category: 'senior managers and execs',
    women: 58101,
    men: 79329,
    gap: 21228,
    percentage: 0.3603,
  },
  {
    occupation: 'Financial advisors',
    category: 'senior managers and execs',
    women: 52208,
    men: 85124,
    gap: 32916,
    percentage: 0.6305,
  },
  {
    occupation: 'Financial managers',
    category: 'senior managers and execs',
    women: 58604,
    men: 86892,
    gap: 28288,
    percentage: 0.4827,
  },
  {
    occupation: 'Chief executives',
    category: 'senior managers and execs',
    women: 81744,
    men: 116792,
    gap: 35048,
    percentage: 0.4288,
  },
  {
    occupation: 'Management analysts',
    category: 'senior managers and execs',
    women: 64428,
    men: 86580,
    gap: 22152,
    percentage: 0.3438,
  },
  {
    occupation: 'Financial operations',
    category: 'senior managers and execs',
    women: 54912,
    men: 73632,
    gap: 18720,
    percentage: 0.3409,
  },
  {
    occupation: 'Business operations',
    category: 'senior managers and execs',
    women: 49088,
    men: 63908,
    gap: 14820,
    percentage: 0.3019,
  },
  {
    occupation: 'Management',
    category: 'senior managers and execs',
    women: 58604,
    men: 75608,
    gap: 17004,
    percentage: 0.2902,
  },
  {
    occupation: 'Financial analysts',
    category: 'senior managers and execs',
    women: 63648,
    men: 77636,
    gap: 13988,
    percentage: 0.2198,
  },
  {
    occupation: 'Office supervisor',
    category: 'senior managers and execs',
    women: 39676,
    men: 47788,
    gap: 8112,
    percentage: 0.2045,
  },
  {
    occupation: 'All occupations average',
    women: 42959,
    men: 54137,
    gap: 11178,
    percentage: 0.2475,
  },
]
